package com.wanho.qz103.hrsaas.sys.contoller;

import com.wanho.qz103.hrsaas.commons.annontations.Autowired;
import com.wanho.qz103.hrsaas.commons.annontations.GetMapping;
import com.wanho.qz103.hrsaas.commons.annontations.RestController;
import com.wanho.qz103.hrsaas.commons.exception.ControllerException;
import com.wanho.qz103.hrsaas.commons.exception.ServiceException;
import com.wanho.qz103.hrsaas.commons.vo.R;
import com.wanho.qz103.hrsaas.sys.pojos.Permission;
import com.wanho.qz103.hrsaas.sys.service.PermissionService;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
public class PermissionController {
    @Autowired
    private PermissionService permissionService ;

    @GetMapping("/sys/permission")
    public R list(HttpServletRequest request) throws ControllerException{
        try {
            List<Permission> permissionList = permissionService.list() ;
            return R.success("获得权限列表成功!",permissionList) ;
        } catch (ServiceException e) {
            e.printStackTrace();
            throw new ControllerException(e.getMessage()) ;
        }
    }
}
